import request from 'lib/request';

// 获取个人资料
export function queryProfile(hospitalId, patientId) {
  let body = {
    hospitalId,
    patientId,
  }
  return request("wechat/patient/detail?"+"hospitalId="+hospitalId+"&patientId="+patientId,{
    method: "GET",
  })
}
// 上传个人头像
export function queryHeadPortrait(patientId, hospitalId, mediaId){
  const body = new FormData();
  body.append('patientId', patientId);
  body.append('mediaId', mediaId);
  body.append('hospitalId', hospitalId);
  return request.post('wechat/patient/uploadHeadPortrait', { body });
}

// 修改个人资料
export function updateProfile(data) {
  const body = new FormData();
  body.append('hospitalId', JSON.parse(localStorage.getItem("auth"+sessionStorage.getItem("hid"))).hospitalId);
  body.append('mobile', JSON.parse(localStorage.getItem("auth" + sessionStorage.getItem("hid"))).mobile);
  Object.keys(data).forEach(key => body.append(key, data[key]));
  return request.post('wechat/patient/updatePatient', { body });
}

// 修改密码
export function updatePassword(data) {
  const body = new FormData();
  body.append('hospitalId', JSON.parse(localStorage.getItem("auth"+sessionStorage.getItem("hid"))).hospitalId);
  Object.keys(data).forEach(key => body.append(key, data[key]));
  return request.post('wechat/patient/updatePwd', { body });
}

// 修改绑定手机
// data: { oldmobile, oldcode, mobile, code }
export function updateMobile(data) {
  const body = new FormData();
  body.append('hospitalId', JSON.parse(localStorage.getItem("auth"+sessionStorage.getItem("hid"))).hospitalId);
  Object.keys(data).forEach(key => body.append(key, data[key]));
  return request.post('wechat/patient/updateMobile', { body });
}

// 获取测评模块
export function queryGetModules (hospitalId){
  let body = {
    hospitalId,
  }
  return request("wechat/eva/getModules?"+"hospitalId="+hospitalId,{
    method: "GET",
  })
}